// Laplace.fx 

// #######################
// ##### PARAMENTERS #####

sampler samplerState;

// Main pass pixel shader
struct PixelShaderInput
{
	float2 texCoord        : TEXCOORD0; // interpolated texture coordinates
};

uniform float scale = 1.0;
uniform float pixelSize = 0.0031;

// #######################
// ##### PIXELSHADER #####

// Main pass pixel shader
float4 PixelShader (PixelShaderInput input) : COLOR
{

   float2 samples[4] = {
        0, -1,
       -1,  0,
        1,  0,
        0,  1
    };
   float4 laplace = -4 * tex2D(samplerState, input.texCoord);

   // Sample the neighbor pixels
   for (int i = 0; i < 4; i++){
      laplace += tex2D(samplerState, input.texCoord + pixelSize * samples[i]);
   }

   return (0.5 + scale * laplace);
}

technique Laplace {
		pass P0{ 
			PixelShader = compile ps_2_0 PixelShader(); 
		}
}